package com.bdqn.controller;

import com.bdqn.pojo.Result;
import com.bdqn.utils.AliOssUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class FileUploadController {

    @PostMapping("/upload")
    public Result<String> upload(MultipartFile file) throws Exception {
        //把文件内容存储到本地
        String originalFilename = file.getOriginalFilename();
//        file.transferTo(new File("D:\\截图\\"+originalFilename));
       String URL =  AliOssUtil.uploadFile(originalFilename,file.getInputStream());
        return Result.success(URL);
    }
}
